package com.ccp.dev.extend.dao;

import com.ccp.dev.system.model.SysOrg;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface ExtendSysOrgDao {

    @Select("select * from (\n" +
            "SELECT\n" +
            "\tt1.PATH,\n" +
            "\tt2.* \n" +
            "FROM\n" +
            "\tSYS_ORG t1 LEFT JOIN SYS_TENANT_ORG t2 ON t1.ORGID = t2.ORG_ID \n" +
            "WHERE\n" +
            "\tt2.TENANT_ID = ( SELECT TENANT_ID FROM SYS_TENANT_ORG WHERE ORG_ID = #{orgId} ) \n" +
            "ORDER BY\n" +
            "\tpath  )  WHERE rownum < 2")
    Map<String,Object> selectOrg(@Param("orgId") String orgId);

    /**
     * 根据租户id查找组织列表
     * @param tenantId
     * @return 返回查询到的组织列表信息
     * @author 创新中心-王明亮
     */
    List<SysOrg> getOrgsByTenantId(String tenantId);

}
